const mongoose = require('./db')

const ObjectId = mongoose.Schema.Types.ObjectId

const HistorySchema = new mongoose.Schema({
  username: { type: String, required: true, index: true, display: '管理员姓名' },
  user: { type: ObjectId, required: false, ref: 'Admin', display: '管理员ID' },
  path: { type: String, required: true, default: '/', display: '目标' },
  method: { type: String, required: true, default: 'GET', display: '操作方法' },
  state: { type: Number, required: true, default: 200, display: '状态' },
  desc: { type: String, display: '操作说明' },
}, {
  collection: 'History',
  timestamps: {
    createdAt: true,
    updatedAt: false,
  },
})

const History = mongoose.model('History', HistorySchema)

module.exports = History